package com.matrix.java.chap_04;

import java.util.Arrays;
import java.util.Scanner;

/*
    一个月中的日期
 */
public class Ex4_17 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter a year: ");
        int year = input.nextInt();
        System.out.print("Enter a month: ");
        String month = input.next();
        int monthDays;
        if (month.equals("Feb")) {
            if (year % 400 == 0) {
                monthDays = 29;
            } else if (year % 4 == 0 && year % 100 != 0) {
                monthDays = 29;
            } else {
                monthDays = 28;
            }
        } else if (Arrays.asList("Jan", "Mar", "May", "Jul", "Aug", "Oct", "Dec").contains(month)) {
            monthDays = 31;
        } else {
            monthDays = 30;
        }
        System.out.println(monthDays);
        input.close();
    }
}
